package inorderTraversal94;

import java.util.ArrayList;
import java.util.List;

public class InorderTraversal {
    public List<Integer> inorderTraversal(TreeNode root) {

        ArrayList<Integer> list = new ArrayList<>();
        preOrder(root,list);
        return list;
    }

    //前序遍历 -递归方式
    public void preOrder(TreeNode root, ArrayList<Integer> res){
        res.add(root.val);
        preOrder(root.left, res);
        preOrder(root.right, res);
    }
}




class TreeNode {
     int val;
     TreeNode left;
     TreeNode right;
     TreeNode() {}
     TreeNode(int val) { this.val = val; }
     TreeNode(int val, TreeNode left, TreeNode right) {
         this.val = val;
         this.left = left;
         this.right = right;
     }
 }
